import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 圣言术-盾
 **/
export default class MS_HolyShield extends AbilityBase {
    static instance: MS_HolyShield;
    buffType: AppBuffType = {
        id: 'buff_MS_HolyShield',
        art: this.art,
        name: this.abilityName,
        ubertip: '圣光在保护着你',
        dur: 15,
        targetAttach: 'origin',
        targetArt: '光圈\\sem_guang_quan.mdx',
        onDestroy: this.buffEnd.bind(this),
    };
    constructor(id: string) {
        super(id);
        MS_HolyShield.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({ target, caster: source, ablityId: this.id, buffTypeId: this.buffType.id });
        let lv = this.getAbilityLevel(source);
        let val = 100 + 80 * lv + UnitCommon.取法强(source) * (1 + 0.5 * lv);
        ShieldSystem.添加护盾值(target, this.buffType.id, val, false, source);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    buffEnd(buff: Buff) {
        ShieldSystem.移除指定护盾(buff.getParent(), this.buffType.id, buff.getCaster());
    }
}
